#ifndef _MEM_H_
#define _MEM_H_

#include "config.h"

#ifndef NULL
#define NULL 0
#endif //NULL

#if MEM_DEBUG

void* operator new(size_t size, const char* src_file, int src_line);
void* operator new[](size_t size, const char* src_file, int src_line);
void* operator new(size_t size) throw();
void* operator new[](size_t size);

void operator delete(void* ptr, const char* src_file, int src_line);
void operator delete[](void* ptr, const char* src_file, int src_line);
void operator delete(void* ptr) throw();
void operator delete[](void* ptr);


#define DEBUG_NEW new(__FILE__, __LINE__)
#define new DEBUG_NEW

#define DEL(x) operator delete(x,__FILE__,__LINE__)
#define DEL_ARRAY(x) operator delete[](x,__FILE__,__LINE__)


#else //MEM_DEBUG

#define DEL(x) operator delete(x)
#define DEL_ARRAY(x) operator delete[](x)

#endif //MEM_DEBUG

#define NEW(x) new x
#define SAFE_DEL(x) {if (x) {DEL(x); x = NULL;}}
#define SAFE_DEL_ARRAY(x) {if (x) {DEL_ARRAY(x); x = NULL;}}



#endif //_MEM_H_